Fix Android issue with isUserInteraction always returning true when location puck is pulsing#4222
Conversation
… gestures being tracked that could lead to race conditions
…t map steady event detection is decoupled and can be minimally reused from RNMBXMapView
…ent kotlin components - refactor MapSteadyDetector so that it uses enum instead of magic strings
|
@KijongHan thanks much for the PR. I'd rather add onRegionIsChanging or similar even to CameraGestureObserver. And kinda deprecate |
thanks for reviewing these changes @mfazekas ! Just wanted to get some clarification on your suggestion. Do you mean deprecate If you mean the former, do you mean that we want to keep the underlying |
To clarify: deprecate onRegionIsChanging (the MapView event), not onMapSteady. RNMBXMapView is already too complicated and the long-term plan is to split it into components — so I'd rather move code out of MapView, not into it. Concretely: CameraGestureObserver gains an onRegionIsChanging-like event (say onCameraChange) reporting isUserInteraction from its own gesture/animator tracking. Since it doesn't depend on MapIdle, it's immune to the pulsing puck issue. The MapView event stays as-is natively and gets deprecated in the JS API, so #3805 is addressed by migrating to the new event. Extracting MapSteadyDetector as a helper is fine — it should just stay owned by CameraGestureObserver, and the CameraChangeTracker changes wouldn't be needed. |
Description
Fixes #3805
Fixes Android bug where
onRegionIsChanging'sproperties.isUserInteractionwas stucktruewhenever<LocationPuck pulsing="default" />was mounted, even if there were no user action. Root cause: the LocationComponent's pulsing animator keeps the map perpetually non-idle (as reported here), so Mapbox'sMapIdleevent never fires.This means that
CameraChangeTrackernever cleared user gesture state asaddOnMapIdleListenernever fired if that<LocationPuck />component was mounted. Fix was to use the new customMapSteadyevent already introduced here #4074Changes
CameraChangeTrackerand replace singlereason: CameraChangeReasonfield withreasonByGesture: Map<MapGestureType, CameraChangeReason>so concurrent move/scale/rotate gestures don't cause race conditions.MapSteadyDetectorfromRNMBXCameraGestureObserverand use this custom event fromRNMBXMapViewto drive clearing theCameraChangeTrackerstate which corrects the downstream propagation toproperties.isUserInteractionMapGestureTypeis promoted to shared enumChecklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)Component to reproduce the issue you're fixing
Just pasting the same repro code snippet provided by the original issue